<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%@ taglib prefix="sb" uri="/struts-bootstrap-tags"%>
<%@ include file="/page/common/admHeader.jsp" %>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>企业管理列表</title>
<script type="text/javascript" src="<%=basePath%>js/tablecreate/jlinq.js"></script>
<script type="text/javascript" src="<%=basePath%>js/tablecreate/jquery-dynamicTable.js"></script>
<script type="text/javascript" src="<%=basePath%>js/tablecreate/pager.js"></script> 
<script type="text/javascript" src="<%=basePath%>js/tablecreate/modal.js"></script>

<style type="text/css">
a:LINK{text-decoration: none;color:black;}
a:visited {text-decoration:none ; color:black;}
a:hover {text-decoration:underline ; color:black;}
a:active {text-decoration:none ; color:black;} 


</style>

<sb:head/>
</head>
<body  onload="adminCompanyList()">

<h3>企业列表</h3>
<div style="background-color:#dcdcdc;width: 100%;height:36px;">
<div style="background-color:#dcdcdc;width: 500px;height:36px;float:left;">
<input  class="btn btn-info" onclick="plus('com_editCompany')" type="button" value="添加企业" />
<input placeholder="请输入公司名称"  id="comName" class="input-medium search-query" name="comName" value=""/>
<select id="status" style="width:100px;">
<option value="">账户状态</option>
<option value=1>启用</option>
<option value=0>停用</option>
</select>
<input style="margin-top: -7px;" type="button" class="btn btn-success" id="" onclick="searchList()" value="查询"/>
</div>
<div style="background-color:#dcdcdc;width: 360px;height:36px;float:right;">
<select id="selDate" onchange="searchListByselDate()" style="width: 80px;height: 80%" >
<option value="">时间</option>
<option value='<s:property value="dateMap.currDate"/>-<s:property value="dateMap.currDate"/>'>今天</option>
<option value='<s:property value="dateMap.yesterday"/>-<s:property value="dateMap.currDate"/>'>昨天</option>
<option value='<s:property value="dateMap.day7"/>-<s:property value="dateMap.currDate"/>'>最近7天</option>
<option value="<s:property value="dateMap.day15"/>-<s:property value="dateMap.currDate"/>">最近15天</option>
<option value="<s:property value="dateMap.currMonth"/>-<s:property value="dateMap.currDate"/>">本月</option>
<option value="<s:property value="dateMap.upstartmonth"/>-<s:property value="dateMap.upendmonth"/>">上月</option>
</select>
<input placeholder="起始时间" id="sDate" type="text" style="width: 120px;height: 80%" onClick="WdatePicker()"/><input placeholder="结束时间" onchange="searchListByDate()" id="eDate" style="width: 120px;height: 80%" type="text" onClick="WdatePicker()"/>
<img style="margin-top: -10px;" width="30px;" height="35px;" alt="" src="<%=basePath%>js/datepicker/skin/datePicker.gif">
</div>
</div>
<div id="lists">
<div id="list" ></div>
<div id="page"></div>
</div>
<script type="text/javascript">
var url=[{loadUrl:"com_getComs",editUrl:"com_editCompany?comId=",stopUrl:""}];//请求地址
var postData={comName:$("#comName").val(),status:$("#status").val()};
var pageId="page";
var objClassName="list_light";
var objColumn = [//这里应该还有加上企业收益
					{ ColumnName: "企业名称", DataId: "comName", Width: 200, DataAlign: "left", Format: null, OnClick: null },
					{ ColumnName: "邮箱", DataId: "comEmail", Width: 100, DataAlign: "left", Format: null, OnClick: null },
					{ ColumnName: "注册人", DataId: "comUser", Width: 100, DataAlign: "left", Format: null, OnClick: null },
					{ ColumnName: "企业地址", DataId: "comAddres", Width: 100, DataAlign: "left", Format: null, OnClick: null },
					{ ColumnName: "联系电话", DataId: "comPhone", Width: 100, DataAlign: "left", Format: null, OnClick: null },
					{ ColumnName: "利润", DataId: "profit", Width: 100, DataAlign: "left", Format: null, OnClick: null },
					{ ColumnName: "创建时间", DataId: "created", Width:200, DataAlign: "left", Format: null, OnClick: null },
					{ ColumnName: "操作", DataId: "Operation", Width: 200, DataAlign: "left", Format: null, OnClick: null },
                 ];
function adminCompanyList(){
	   $.ajax({
			type: "post",
	        url: url[0].loadUrl,
	        data: postData,
	        dataType: "json",
	        success: function(data){
          var objData = new Array(data.list.length);
          for(var i=0;i<data.list.length;i++){
              if(data.list[i].status==1){
            	  var op="<a class='edit'onclick=\"edit('"+url[0].editUrl+""+data.list[i].comId+"')\" title=\"编辑\" href=\"javascript:void(0)\" id='"+data.list[i].comId+"'>编辑</a>&nbsp;&nbsp;<a href='javascript:void(0)' onclick=edit('com_editPower?comId="+data.list[i].comId+"') >编辑权限</a>&nbsp;&nbsp;<a href='com_updateStatus?comId="+data.list[i].comId+"&status=0'>停用</a>&nbsp;&nbsp;<a href='com_intoAccount?comId="+data.list[i].comId+"&comName='"+data.list[i].comName+"  target='_bank' '>进入帐号</a>";
                  }else{
                  var op="<a class='edit' onclick=\"edit('"+url[0].editUrl+""+data.list[i].comId+"')\" title=\"编辑\" href=\"javascript:void(0)\" id='"+data.list[i].comId+"'>编辑</a>&nbsp;&nbsp;<a href='javascript:void(0)' onclick=edit('com_editPower?comId="+data.list[i].comId+"') >编辑权限</a>&nbsp;&nbsp;<a href='com_updateStatus?comId="+data.list[i].comId+"&status=1'>启用</a>&nbsp;&nbsp;<a href='com_intoAccount?comId="+data.list[i].comId+"&comName='"+data.list[i].comName+" target='_bank''>进入帐号</a>";
                      }
        	  objData[i]={comName:data.list[i].comName,comEmail:data.list[i].comEmail,
        			  comUser:data.list[i].comUser,comAddres:data.list[i].comAddres,
        			  comPhone:data.list[i].comPhone,profit:data.list[i].profit,
                	  created:data.list[i].created,Operation:op}; 
              }
               $("#list").MakeTable(objColumn, objData, objClassName);
        	  $("#page").MakePage(data.page[0]);
		        }
			});
	   }
function searchList(){
	var page=$("#selPage").val();
	var pageRow=$("#selRow").val();
	postData={comName:$("#comName").val(),status:$("#status").val(),initPage:page,pageRow:pageRow};
	adminCompanyList();
}
var j=0;
function OrderSort(order){
	var order=order;
	j++;
	if(j%2==0){
          var sort="desc";
		}else if (j%3==0) {
			var sort="asc";
		}else{
      order="created";
      var sort="desc";
			}
	var page=$("#selPage").val();
	var pageRow=$("#selRow").val();
	postData={comName:$("#comName").val(),status:$("#status").val(),order:order,sort:sort,initPage:page,pageRow:pageRow};
	adminCompanyList();
}
function goPage(){
	var page=$("#selPage").val();
	var pageRow=$("#selRow").val();
	postData={comName:$("#comName").val(),status:$("#status").val(),initPage:page,pageRow:pageRow};
	adminCompanyList();
}
function changePage(page){
	var pageRow=$("#selRow").val();
	postData={comName:$("#comName").val(),status:$("#status").val(),initPage:page,pageRow:pageRow};
	adminCompanyList();
}
function goRow(){
	var pageRow=$("#selRow").val();
	var page=$("#selPage").val();
	adminCompanyList();
}
function searchListByselDate(){
    var date=$("#selDate").val();
  //  alert(date);
    var sDate=date.substring(0,(date.length-1)/2);
    var eDate=date.substring((date.length+1)/2,date.length);
    ///alert(sDate);alert(eDate);
    var page=$("#selPage").val();
	var pageRow=$("#selRow").val();
	postData={comName:$("#comName").val(),status:$("#status").val(),s_date:sDate,e_date:eDate,initPage:page,pageRow:pageRow};
	adminCompanyList();
}
function searchListByDate(){
	var sDate=$("#sDate").val();
	var eDate=$("#eDate").val();
	//alert(sDate);alert(eDate);
	var page=$("#selPage").val();
	var pageRow=$("#selRow").val();
	postData={comName:$("#comName").val(),status:$("#status").val(),s_date:sDate,e_date:eDate,initPage:page,pageRow:pageRow};
	adminCompanyList();
}
</script>
<%@ include file="/page/common/modal.jsp"%>
<%@ include file="/page/common/admFooter.jsp"%>
</body>
</html>